cmake_minimum_required(VERSION 3.22)
project(Sofa.Component.Engine.Transform LANGUAGES CXX)

set(SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR "src/sofa/component/engine/transform")

set(HEADER_FILES
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/config.h.in
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/init.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DifferenceEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DifferenceEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DilateEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DilateEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DisplacementMatrixEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DisplacementMatrixEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/IndexValueMapper.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/IndexValueMapper.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Indices2ValuesMapper.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Indices2ValuesMapper.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MapIndices.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MapIndices.inl    
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MathOp.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MathOp.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/ProjectiveTransformEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/ProjectiveTransformEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/QuatToRigidEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/QuatToRigidEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/ROIValueMapper.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/RigidToQuatEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/RigidToQuatEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/SmoothMeshEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/SmoothMeshEngine.inl    
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformEngine.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformMatrixEngine.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformPosition.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformPosition.inl
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Vertex2Frame.h
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Vertex2Frame.inl

)

set(SOURCE_FILES
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/init.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DifferenceEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DilateEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/DisplacementMatrixEngine.cpp    
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/IndexValueMapper.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Indices2ValuesMapper.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MapIndices.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/MathOp.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/ProjectiveTransformEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/QuatToRigidEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/ROIValueMapper.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/RigidToQuatEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/SmoothMeshEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformMatrixEngine.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/TransformPosition.cpp
    ${SOFACOMPONENTENGINETRANSFORM_SOURCE_DIR}/Vertex2Frame.cpp
)

sofa_find_package(Sofa.Simulation.Core REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)

sofa_create_package_with_targets(
    PACKAGE_NAME ${PROJECT_NAME}
    PACKAGE_VERSION ${Sofa_VERSION}
    TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
    INCLUDE_SOURCE_DIR "src"
    INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFA_COMPONENT_ENGINE_TRANSFORM_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
if(SOFA_COMPONENT_ENGINE_TRANSFORM_BUILD_TESTS)
    enable_testing()
    add_subdirectory(tests)
endif()
